﻿using System;
using System.Collections.Generic;
using System.Linq;
using Model.Entity;
using Ones.Dal.Repository.Impl;

namespace Ones.Wcf.WebAdministration
{
    public class ServiceUploadManagement : IServiceUploadManagement
    {
        private IMediaDao _dao;

        #region Constructor
        
        public ServiceUploadManagement()
        {
            _dao = new MediaDao();
        }
        
        #endregion
        
        #region DMM
        
        public bool
        saveMedia(Media media)
        {
            try
            {
                media.mDateCreate = DateTime.Now;
                return _dao.create(media);
            }
            catch (Exception)
            {
                return false;
            }
        }

        #endregion
        
        #region DQM
        
        public List<Media>
        searchAllMedia()
        {
            return _dao.getAll();
        }
        
        public Media
        searchMediaById(int id)
        {
            return _dao.getById(id);
        }
        
        public List<Media>
        searchMediaByName(string name)
        {
            return _dao.getByName(name);
        }
        
        public List<Media>
        searchMediaByType(string type)
        {
            return _dao.getByType(type);
        }
        
        #endregion
    }
}